package io.shuttle.mbe_app.permission

import androidx.compose.runtime.Composable

@Composable
public fun rememberMultiplePermissionsState(
    permissions: List<String>,
    onPermissionsResult: (Map<String, Boolean>) -> Unit = {}
): MultiplePermissionsState {
    return rememberMutableMultiplePermissionsState(permissions, onPermissionsResult)
}


public interface MultiplePermissionsState {

    /**
     * List of all permissions to request.
     */
    public val permissions: List<PermissionState>

    /**
     * List of permissions revoked by the user.
     */
    public val revokedPermissions: List<PermissionState>

    /**
     * When `true`, the user has granted all [permissions].
     */
    public val allPermissionsGranted: Boolean

    /**
     * When `true`, the user should be presented with a rationale.
     */
    public val shouldShowRationale: Boolean

    /**
     * Request the [permissions] to the user.
     *
     * This should always be triggered from non-composable scope, for example, from a side-effect
     * or a non-composable callback. Otherwise, this will result in an IllegalStateException.
     *
     * This triggers a system dialog that asks the user to grant or revoke the permission.
     * Note that this dialog might not appear on the screen if the user doesn't want to be asked
     * again or has denied the permission multiple times.
     * This behavior varies depending on the Android level API.
     */
    public fun launchMultiplePermissionRequest(): Unit
}